package cn.myjerry.io.charIO;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * 纯文本的读取
 * @author Jerry
 *
 */
public class Demo01 {
	public static void main(String[] args) {
		String path = "/Users/zpon/Desktop/test.txt";
		File src = new File(path);
		Reader re = null;
		try {
			re = new FileReader(src);
			char[] car = new char[10];
			int len = 0;
			while(-1 != (len = re.read(car))) {
				String str = new String(car, 0, len);
				System.out.println(str);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.out.println("源文件不存在");
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("文件读取失败");
		} finally {
			try {
				if(null == re) {
					re.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("关闭流失败");
			}
		}
	}
}
